package com.iknow.ui.model;

import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;
import com.iknow.data.Comment;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.List;

public class CommentListAdapter extends BaseAdapter
{
  private List<Comment> mCommentList;
  private SimpleDateFormat mDateFormatTime;
  protected LayoutInflater mInflater = null;
  private SimpleDateFormat mSimpleFormatTime;

  public CommentListAdapter(LayoutInflater paramLayoutInflater)
  {
    this.mDateFormatTime = new SimpleDateFormat("MM-dd HH:mm");
    this.mSimpleFormatTime = new SimpleDateFormat("HH:mm");
    this.mInflater = paramLayoutInflater;
    this.mCommentList = new ArrayList();
  }

  private void fillDataToView(int paramInt, View paramView)
  {
    Comment localComment = (Comment)this.mCommentList.get(paramInt);
    ViewHolder localViewHolder = (ViewHolder)paramView.getTag();
    localViewHolder.username.setText(localComment.getUName());
    localViewHolder.usercomment.setText(localComment.getData());
    localViewHolder.commentdate.setText(localComment.getDate());
  }

  private View newView()
  {
    View localView = this.mInflater.inflate(2130903046, null);
    ViewHolder localViewHolder = new ViewHolder(this);
    localViewHolder.username = ((TextView)localView.findViewById(2131296287));
    localViewHolder.usercomment = ((TextView)localView.findViewById(2131296289));
    localViewHolder.commentdate = ((TextView)localView.findViewById(2131296288));
    localView.setTag(localViewHolder);
    return localView;
  }

  public void addComment(Comment paramComment)
  {
    this.mCommentList.add(0, paramComment);
  }

  public void addComments(List<Comment> paramList)
  {
    this.mCommentList.addAll(paramList);
  }

  public int getCount()
  {
    return this.mCommentList.size();
  }

  public Comment getItem(int paramInt)
  {
    return ((Comment)this.mCommentList.get(paramInt));
  }

  public long getItemId(int paramInt)
  {
    return paramInt;
  }

  public View getView(int paramInt, View paramView, ViewGroup paramViewGroup)
  {
    if (paramView == null)
      paramView = newView();
    fillDataToView(paramInt, paramView);
    return paramView;
  }

  public class ViewHolder
  {
    TextView commentdate;
    TextView usercomment;
    TextView username;
  }
}